package com.yhy.dubbo.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yhy.domain.BlackList;
import com.yhy.domain.UserInfo;
import com.yhy.dubbo.api.BlackListApi;
import com.yhy.mapper.BlackListMapper;
import com.yhy.mapper.UserInfoMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class BlackListApiImpl implements BlackListApi {

    @Autowired
    private BlackListMapper blackListMapper;

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public IPage<UserInfo> findPage(Integer page, Integer pagesize, Long userId) {
        Page<UserInfo> pages = new Page<>(page,pagesize);
        return userInfoMapper.findBlackList(pages,userId);
    }

    @Override
    public void deleteBlackList(Long userId, Long blackUserId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("user_id",userId);
        queryWrapper.eq("black_user_id",blackUserId);
        blackListMapper.delete(queryWrapper);
    }
}